home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr01 / halcn305.zip / GSDMO_16.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-02  |  4KB  |  148 lines

  1. program GSDMO_16;
  2. {------------------------------------------------------------------------------
  3.                     DBase File and Memo Editor (External)
  4.  
  5.        Copyright (c)  Richard F. Griffin
  6.  
  7.        20 January 1993
  8.  
  9.        102 Molded Stone Pl
  10.        Warner Robins, GA  31088
  11.  
  12.        -------------------------------------------------------------
  13.        This program reads a dBase file 'GSDMO_07.DBF with memo file
  14.        'GSDMO_07.DBT'.   It uses an external editor to work with the
  15.        memo fields.  Use F4 in the editor to exit. The program will
  16.        stop when the editor is exited without updating.
  17.  
  18.             --- WILL NOT COMPILE AS A WINDOWS APPLICATION ---
  19.  
  20.        About the external editor:
  21.  
  22.                               TEXT EDITOR 2.5
  23.  
  24.        Text Editor (TE) 2.5 is a public domain, full screen ASCII text
  25.        editor for the IBM PC and close compatibles which uses commands
  26.        similar to those used in WordStar and Sidekick.  Primary uses for
  27.        TE are to create/edit batch files, generate forms, edit files cap-
  28.        tured by telecommunications programs, write E-mail and simulate a
  29.        "smart" typewriter.
  30.  
  31.        Features include: 1) Program size of 29,904 bytes.  2) Edit file
  32.        size as large as available memory.  3) Display commands on pop-up
  33.        help screen, prompt for subcommands.  4) Insert, delete, split, join
  34.        a line.  5) Copy, delete, move, read, write, shift, hide, display a
  35.        marked block.  6) Print a file/block to LPT1-LPT3.  7) Enter any
  36.        ASCII code.  8) Find/replace a phrase.  9) Temporary return to DOS.
  37.        10) Set left/right margins and page length.  11) Word wrap.
  38.        12) Format (justify) a paragraph.
  39.  
  40.        This archive contains the following files:
  41.           TEREAD.1ST   This file.
  42.           TE.EXE       The actual Text Editor program.
  43.           TE.DOC       TE 2.5 User's Guide (10 pages).
  44.           TEMOD.EXE    Utility to change TE.EXE colors, cursor size, margins,
  45.                        etc.
  46.           TEG.HLP      TE 2.5 Command Summary (1 page).
  47.  
  48.        Written by:  John Haluska,
  49.                     310 W. Imperial Ave. #6,
  50.                     El Segundo, CA 90245.
  51.                     CompuServe 74000,1106
  52.  
  53. -------------------------------------------------------------------------------}
  54.  
  55. {$M 8192,0,65536}      {Needed to allow room for the 'Exec'ed editor}
  56.  
  57. uses
  58.    CRT,
  59.    Dos,
  60.    GSOB_Dsk,
  61.    GSOBShel;
  62. const
  63.    TxFileName = 'GSDMO_07.MMO';
  64. var
  65.    TxFile  : Text;
  66.    t1      : longint;
  67.    t2      : longint;
  68.    c       : char;
  69.    domore  : boolean;
  70.  
  71.                      {Procedure to display the memo field}
  72.  
  73. procedure MemoToDiskFile(fldname: string);
  74. var
  75.    i,
  76.    ml   : integer;
  77.  
  78. begin
  79.    Rewrite(TxFile);
  80.    MemoGet('COMMENTS');
  81.    ml := MemoLines;
  82.    if ml <> 0 then
  83.       for i := 1 to ml do
  84.          Writeln(TxFile,MemoGetLine(i))
  85.    else
  86.    Writeln(TxFile,' ');               {at least one byte in the file}
  87.    Close(TxFile);
  88. end;
  89.  
  90. procedure DiskFileToMemo(fldname: string);
  91. var
  92.    i   : integer;
  93.    s   : string;
  94.    m1,
  95.    m2  : string[10];
  96. begin
  97.    m1 := FieldGet('COMMENTS');
  98.    MemoClear;
  99.    Reset(TxFile);
  100.    while not EOF(TxFile) do
  101.    begin
  102.       Readln(TxFile,s);
  103.       MemoInsLine(-1,s);
  104.    end;
  105.    Close(TxFile);
  106.    MemoPut('COMMENTS');
  107.    m2 := FieldGet('COMMENTS');
  108.             {If the memo field number has changed, save the DBF record}
  109.    if m1 <> m2 then Replace;
  110. end;
  111.  
  112.                                {Main program}
  113. begin
  114.    ClrScr;
  115.    domore := true;
  116.  
  117.    if not FileExist('GSDMO_07.DBF') then
  118.    begin
  119.       writeln('File GSDMO_07.DBF not found.  Run GSDMO_07 to create.');
  120.       halt;
  121.    end;
  122.                        {The 'Real' example starts here}
  123.  
  124.    Assign(TxFile,TxFileName);
  125.    Rewrite(TxFile);
  126.  
  127.    Use('GSDMO_07');
  128.    MemoWidth(75);        {sets width of the memo line.  Default is 50}
  129.    GoTop;
  130.    while not dEOF and domore do
  131.    begin
  132.       ClrScr;
  133.       writeln(FieldGet('LASTNAME'),', ',
  134.               FieldGet('FIRSTNAME'));
  135.       MemoToDiskFile('COMMENTS');
  136.       if FileExist(TxFileName) then t1 := FindFileInfo.Time;
  137.       Exec('TE.EXE',TxFileName);
  138.       if FileExist(TxFileName) then t2 := FindFileInfo.Time;
  139.       if t1 <> t2 then                {File was updated}
  140.          DiskFileToMemo('COMMENTS')
  141.       else
  142.          domore := false;
  143.       Skip(1);
  144.    end;
  145.    CloseDataBases;
  146. end.
  147.  
  148.